package dp;

/**
 * @author : Rookie
 * @description : 爬楼梯
 * @date : 2024/1/12
 */
public class ClimbStairsI {

    public static void main(String[] args) {
        int n = 5;
        System.out.println(climb(n));
    }

    private static int climb(int n) {
        int[] dp = new int[n];
        // 爬到1层有1种方法
        dp[1] = 1;
        // 爬到2层有2种方法
        dp[2] = 2;
        for (int i = 3; i < dp.length; i++) {
            dp[i] = dp[i-1]+dp[i-2];
        }
        return dp[n-1];
    }
}
